package com.vcourse.service.cms.controller.api;

import com.vcourse.commons.result.R;
import com.vcourse.service.cms.entity.Ad;
import com.vcourse.service.cms.service.AdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Zengsh123
 * @date 2020-06-07 20:27
 */
@Api("广告推荐")
@RestController
@RequestMapping("/api/cms/ad")
public class ApiAdController {

    @Resource
    private AdService adService;

    @ApiOperation("根据推荐位id显示广告推荐")
    @GetMapping("list/{adTypeId}")
    public R listByAdTypeId(@ApiParam(value = "推荐位id", required = true)
                                @PathVariable String adTypeId) {

        List<Ad> ads = adService.selectByAdTypeId(adTypeId);
        return R.ok().data(ads);
    }
}
